PIC24F
PWRMgmt Module Library Help
Table Of Contents
2 Using Library Functions in Your Code
4.1 mPWRMGNT_RecoverOnInterrupt (polarity)
4.2 mPWRMGNT_PeriClkRatioSelect(ratio)
4.3 mPWRMGNT_FRCPostScalerSelect(postscaler)
4.4 mPWRMGNT_FRCOscTuningBits(bits)
4.5 mPWRMGNT_GetClkFailDetectBit()
4.15 mPWRMGNT_Clear_IOPUWRbit()
4.16 mPWRMGNT_Clear_TRAPRbit()
4.17 mPWRMGNT_GetPLL_LockStatus()
This peripheral library module:
· Implements Power Management features of the device.
· Provides functions to switch between operating frequency.
· Provides macros to detect the reset source and to enter the device into IDLE/Sleep modes.
Library routine parameters can be constructed using either AND based mask or AND_OR based mask setting. For more information on these masks, see 16-bit Peripheral Libraries.
Example of Use ( AND_OR mask )
Function Call:
PwrMgnt_ClkDiv_Sel(INTR_CLEAR_DOZEN_BIT | PERI_CLK_RATIO_16 |
PERI_CLK_RATIO_SET_1 | FRC_POSTSCALER_SEL_8);
Function Prototype |
RESET_SOURCE PwrMgnt_ResetSource(void); |
Include |
PwrMgnt.h |
Description |
This function returns the source of reset. |
Arguments |
None |
Return Value |
RESET_SOURCE - Enum value representing the source of the reset. Enum is defined in PwrMgnt.h. |
Remarks: |
None |
Source File: |
PwrMgnt_ResetSource.c |
Function Prototype |
WAKEUP_SOURCE PwrMgnt_WakeupSource(void); |
Include |
PwrMgnt.h |
Description |
This function returns the source of wakeup. |
Arguments |
None |
Return Value |
WAKEUP_SOURCE - Enum value representing the source of the wakeup. Enum is defined in PwrMgnt.h. |
Remarks: |
None |
Source File: |
PwrMgnt_WakeupSource.c |
Function Prototype |
BOOL PwrMgnt_OscSel(UINT16 new_oscsel) |
Include |
PwrMgnt.h |
Description |
This function should be used to select the appropriate oscillator. |
Arguments |
new_oscsel - This parameter is the value of the new oscillator to be selected. |
Return Value |
BOOL - TRUE : If successfully changed new oscillator select bits. FALSE: If 'FCKSM1 = 1' or new oscillator value is same as old oscillator value or PLL is not locked. |
Remarks: |
Global interrupts are disabled while the oscillator is being switched. |
Source File: |
PwrMgnt_OscSel.c |
Function Prototype |
void PwrMgnt_ClkDiv_Sel(UINT16 clk_div_config) |
Include |
PwrMgnt.h |
Description |
This function should be used to select the appropriate oscillator. |
Arguments |
clk_div_config - This parameter is the value of the CLKDIV register. |
Return Value |
None |
Remarks: |
None |
Source File: |
PwrMgnt_ClkDiv_Sel.c |
Macro |
mPWRMGNT_RecoverOnInterrupt (polarity) |
Include |
PwrMgnt.h |
Description |
Sets ROI bitfield polarity. |
Arguments |
polarity - 1 = Interrupts clear the DOZEN bit and reset the CPU peripheral clock ratio to 1:1. 0 = Interrupts have no effect on the DOZEN bit. |
Remarks |
None |
Macro |
mPWRMGNT_PeriClkRatioSelect(ratio) |
Include |
PwrMgnt.h |
Description |
Selects Peripheral Clock Ratio Select bits in DOZE mode. |
Arguments |
ratio - n, where n=0 to 7. DOZE2:DOZE0: CPU Peripheral Clock Ratio Select bits 0b111 = 1:128 0b110 = 1:64 0b101 = 1:32 0b100 = 1:16 0b011 = 1:8 0b010 = 1:4 0b001 = 1:2 0b000 = 1:1 |
Remarks |
None |
Macro |
mPWRMGNT_FRCPostScalerSelect(postscaler) |
Include |
PwrMgnt.h |
Description |
Selects Peripheral Clock Ratio Select bits. |
Arguments |
postscaler - n, where n=0 to 7. RCDIV2:RCDIV0 : CPU Peripheral Clock Ratio Select bits 0b111 = 31.25 kHz (divide by 256) 0b110 = 125 kHz (divide by 64) 0b101 = 250 kHz (divide by 32) 0b100 = 500 kHz (divide by 16) 0b011 = 1 MHz (divide by 8) 0b010 = 2 MHz (divide by 4) 0b001 = 4 MHz (divide by 2) 0b000 = 8 MHz (divide by 1) |
Remarks |
None |
Macro |
mPWRMGNT_FRCOscTuningBits(bits) |
Include |
PwrMgnt.h |
Description |
Selects FRC Osc Tuniing bits. |
Arguments |
bits - TUN5:TUN0: FRC Oscillator Tuning bits 0b011111 = Maximum frequency deviation … 0b000001 0b000000 = Center frequency* 0b111111 … 0b100001 0b100000 = Minimum frequency deviation
* Oscillator is running at factory calibrated frequency. |
Remarks |
None |
Macro |
mPWRMGNT_GetClkFailDetectBit() |
Include |
PwrMgnt.h |
Description |
Returns: 1 = FSCM has detected a clock failure 0 = No clock failure has been detected |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_GotoSleepMode() |
Include |
PwrMgnt.h |
Description |
Enters device into SLEEP mode. |
Arguments |
None |
Remarks |
Device goes into sleep mode. Device will wake if any of the following conditions are satisfied: - On any interrupt source that is individually enabled - On any form of device Reset - On a WDT time-out |
Macro |
mPWRMGNT_GotoIdleMode() |
Include |
PwrMgnt.h |
Description |
Enters device into IDLE mode. |
Arguments |
None |
Remarks |
Device goes into idle mode. Device will wake if any of the following conditions are satisfied: - On any interrupt source that is individually enabled - On any form of device Reset - On a WDT time-out |
Macro |
mPWRMGNT_Clear_PORbit() |
Include |
PwrMgnt.h |
Description |
Clears the Power-On Reset bit. |
Arguments |
None |
Remarks |
This will not clear BOR bit. |
Macro |
mPWRMGNT_GotoIdleMode() |
Include |
PwrMgnt.h |
Description |
Macro to enter device into IDLE mode. |
Arguments |
None |
Remarks |
Device goes into idle mode. Device will wake if any of the following conditions are satisfied: - On any interrupt source that is individually enabled - On any form of device Reset - On a WDT time-out |
Macro |
mPWRMGNT_Clear_BORbit() |
Include |
PwrMgnt.h |
Description |
Clears the Brown-Out Reset bit. |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_Clear_WDTObit() |
Include |
PwrMgnt.h |
Description |
Clears the Watchdog Timer Reset bit. |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_Clear_SWRbit() |
Include |
PwrMgnt.h |
Description |
Clears the Software Reset bit. |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_Clear_EXTRbit() |
Include |
PwrMgnt.h |
Description |
Clears the External Reset bit. |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_Clear_CMbit() |
Include |
PwrMgnt.h |
Description |
Clears the Configuration Word Mismatch Reset bit. |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_Clear_IOPUWRbit() |
Include |
PwrMgnt.h |
Description |
Clears Illegal Instruction Reset bit. |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_Clear_TRAPRbit() |
Include |
PwrMgnt.h |
Description |
Clears trap Reset bit. |
Arguments |
None |
Remarks |
None |
Macro |
mPWRMGNT_GetPLL_LockStatus() |
Include |
PwrMgnt.h |
Description |
Returns: 1 = PLL module is in lock or PLL module start-up timer is satisfied. 0 = PLL module is out of lock, PLL start-up timer is running or PLL is disabled. |
Arguments |
None |
Remarks |
None |